package com.demo.project_template.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.project_template.entity.Report;
import com.demo.project_template.service.ReportService;
import com.demo.project_template.vo.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户举报记录 前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2024-08-20 11:48:57
 */
@Api(tags = "举报记录")
@RestController
@RequestMapping("/report")
public class ReportController {
    @Resource
    private ReportService reportService;

    @ApiOperation(value = "查询举报记录")
    @GetMapping(value = "/page")
    public R<IPage<Report>> page(@RequestParam Integer pageNo,@RequestParam Integer pageSize){
        return R.success(reportService.page(new Page<>(pageNo,pageSize)));
    }

    @ApiOperation(value = "添加举报记录")
    @PostMapping(value = "/add")
    public R<?> add(@RequestBody Report report){
        reportService.save(report);
        return R.success();
    }

    @ApiOperation(value = "修改举报记录")
    @PostMapping(value = "/update")
    public R<?> update(@RequestBody Report report){
        reportService.updateById(report);
        return R.success();
    }

    @ApiOperation(value = "删除举报记录")
    @DeleteMapping(value = "/id")
    public R<?> delete(@RequestParam Long id){
        reportService.removeById(id);
        return R.success();
    }
}
